package com.cssy.xxkj.basic.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.cssy.xxkj.basic.dao.BasicMaterialsTypeDAO;
import com.cssy.xxkj.basic.entity.BasicMaterialsTypeDO;
import com.plat.helper.SearchConditions;

/**
 * 数据访问对象实现类
 * @since 2014-09-10
 */
public class BasicMaterialsTypeDAOImpl extends SqlMapClientDaoSupport implements BasicMaterialsTypeDAO {

    /**
     * 插入数据
     * @param basicMaterialsTypeDO
     * @return 插入数据的主键
     */
    public void insertBasicMaterialsTypeDO(BasicMaterialsTypeDO basicMaterialsTypeDO) {
        getSqlMapClientTemplate().insert("BasicMaterialsType.insert", basicMaterialsTypeDO);
    }

    /**
     * 统计记录数
     * @param basicMaterialsTypeDO
     * @return 查出的记录数
     */
    public Integer countBasicMaterialsTypeDOByExample(BasicMaterialsTypeDO basicMaterialsTypeDO) {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("BasicMaterialsType.countByDOExample", basicMaterialsTypeDO);
        return count;
    }

    /**
     * 获取对象列表
     * @param basicMaterialsTypeDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<BasicMaterialsTypeDO> findListByExample(BasicMaterialsTypeDO basicMaterialsTypeDO) {
        List<BasicMaterialsTypeDO> list = getSqlMapClientTemplate().queryForList("BasicMaterialsType.findListByDO", basicMaterialsTypeDO);
       return list;
    }

	@Override
	public List<BasicMaterialsTypeDO> find(SearchConditions scs)
			throws DataAccessException {
		List<BasicMaterialsTypeDO> list = getSqlMapClientTemplate().queryForList("BasicMaterialsType_ex.find", scs);
		return list;
	}

	@Override
	public Integer count(SearchConditions scs) throws DataAccessException {
		Integer rows = (Integer) getSqlMapClientTemplate().queryForObject("BasicMaterialsType_ex.count", scs);
        return rows;
	}

	@Override
	public Integer deleteBizRemoved(String id) throws DataAccessException {
		Integer rows = (Integer) getSqlMapClientTemplate().queryForObject("BasicMaterialsType_ex.deleteBizRemoved", id);
        return rows;
	}

	@Override
	public Integer updateBasicMaterialsTypeDO(
			BasicMaterialsTypeDO basicMaterialsTypeDO) {
		int result = getSqlMapClientTemplate().update("BasicMaterialsType.update", basicMaterialsTypeDO);
        return result;
	}

	@Override
	public BasicMaterialsTypeDO findBasicMaterialsTypeDOByPrimaryKey(String id) {
		BasicMaterialsTypeDO basicMaterialsTypeDO = (BasicMaterialsTypeDO) getSqlMapClientTemplate().queryForObject("BasicMaterialsType.findByPrimaryKey", id);
		return basicMaterialsTypeDO;
	}

	@Override
	public Integer deleteBasicMaterialsTypeDOByPrimaryKey(String id) {
		Integer rows = (Integer) getSqlMapClientTemplate().delete("BasicMaterialsType.deleteByPrimaryKey", id);
        return rows;
	}
	
	

	@Override
	public List<BasicMaterialsTypeDO> findParentId(String pid) {
		 List<BasicMaterialsTypeDO> list = getSqlMapClientTemplate().queryForList("BasicMaterialsType_ex.findParentId", pid);
	     return list;
	}
}